package org.contacts.dao.impl;

import org.contacts.dao.IDBAdapter;
import org.contacts.dao.IDataAccessObject;

import java.sql.*;

/**
 * Created by nnazarov on 3/28/14.
 */
public class ContactDBA implements IDBAdapter {

    private int id_;
    private String fname_;
    private String lname_;
    private String phone_;

    @Override
    public String getSelect() {
        return "SELECT * FROM contact ";
    }

    public IDataAccessObject loadDAO(IDataAccessObject argDAO) {
        ContactDAO dao = (ContactDAO) argDAO;
        dao.setId_(id_);
        dao.setFname_(fname_);
        dao.setLname_(lname_);
        dao.setPhone_(phone_);
        return dao;
    }

    public void fill(ResultSet argResultSet) throws SQLException{
        id_ = argResultSet.getInt(1);
        fname_ = argResultSet.getString(2);
        lname_ = argResultSet.getString(3);
        phone_ = argResultSet.getString(4);
    }
}
